package com.example.mvvmdemo.repository;

import com.example.mvvmdemo.model.User;
import com.example.mvvmdemo.network.ApiService;
import com.example.common.network.RxHelper;
import com.example.common.utils.LogUtil;
import com.example.common.base.BaseRepository;
import io.reactivex.rxjava3.core.Observable;
import java.util.List;

public class UserRepository extends BaseRepository {
    
    private ApiService apiService;
    
    public UserRepository() {
        super();
        apiService = createService(ApiService.class);
    }
    
    public Observable<List<User>> getUsers(int page, int size) {
        LogUtil.d("UserRepository", "getUsers - page: " + page + ", size: " + size);
        return apiService.getUsers(page, size)
                .compose(RxHelper.handleResult());
    }
    
    public Observable<User> getUserById(int userId) {
        LogUtil.d("UserRepository", "getUserById - userId: " + userId);
        return apiService.getUserById(userId)
                .compose(RxHelper.handleResult());
    }
}